package com.orhon.smartcampus.modules.systemctl.mm;

import java.util.List;

import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import com.orhon.smartcampus.modules.base.mm.DictionaryMapper;
import com.orhon.smartcampus.modules.base.mm.LangMapper;
import com.orhon.smartcampus.modules.systemctl.entity.Widgets;
import com.orhon.smartcampus.modules.systemctl.gqlModel.GQLWidgets;

@Mapper(
        uses = {
                LangMapper.class,
                MenuMapper.class,
                ModuleMapper.class,
                DictionaryMapper.class
        }
)
public interface WidgetsMapper {

    WidgetsMapper MAPPER = Mappers.getMapper(WidgetsMapper.class);

    @Mapping(source ="id" , target = "id")
    @Mapping(source ="title" , target = "title")//lang
    @Mapping(source ="name" , target = "name")
    @Mapping(source ="apis" , target = "apis",qualifiedByName = "StringToList")//数组转list
    @Mapping(source ="type" , target = "type")
    @Mapping(source ="clients" , target = "clients",qualifiedByName = "StringToList")//数组转list
    @Mapping(source ="meta" , target = "meta")
    @Mapping(source ="status" , target = "status")
    @Mapping(source ="createdAt" , target = "created_at")
    @Mapping(source ="updatedAt" , target = "updated_at")
    @Mapping(source ="deletedAt" , target = "deleted_at")
    @Mapping(target = "menu" , ignore = true)
    @Mapping(target = "module" , ignore = true)
    GQLWidgets toWidgets(Widgets moduleentity);

    @InheritConfiguration(name = "toWidgets")
    List<GQLWidgets> toWidgetsList(List<Widgets> entities);


}
